﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

using Finance.Entites;
using Finance.Service.Interfaces;

namespace Finance.Service.Implements
{
    /// <summary>
    /// Store the data with json format in the disk
    /// </summary>
    /// <typeparam name="TEntity">The graph of store object contains in ObserableCollection</typeparam>
    public class MockIncomeClassificationDataStore : JsonDataStore<IncomeClassification>
    {
        private static ObservableCollection<IncomeClassification> _ClassificationCollections = new ObservableCollection<IncomeClassification>();
        public override ObservableCollection<IncomeClassification> Items
        {
            get
            {
                if (base._Items == null || base._Items.Count == 0)
                {
                    _ClassificationCollections.Clear();
                    var classifications = new List<IncomeClassification>(){
                        new IncomeClassification() { Name = "其他" ,Group="其他"},

                        new IncomeClassification() { Name = "工资" ,Group="职业收入"},
                        new IncomeClassification() { Name = "奖金" ,Group="职业收入"},
                        new IncomeClassification() { Name = "外快" ,Group="职业收入"},
                    };

                    foreach (var classification in classifications)
                    {
                        _ClassificationCollections.Add(classification as IncomeClassification);
                    }
                    base._Items = _ClassificationCollections;
                    base.Commit();
                }

                return base._Items;
            }
        }
    }
}
